package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import controle.ControleFuncionario;
import entidades.Funcionario;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TelaFuncionario extends JFrame {

	private JPanel contentPane;
	private JTextField tfFuncionario;
	private JTextField tfData;
	private JTextField tfFone;
	private JTextField tfCpf;
	private JTextField tfRg;
	private JTextField tfSexo;
	private JTextField tfCargo;
	private JTextField tfEstCivil;
	private JTextField tfExpediente;
	private JTextField tfFacebook;
	private JTextField tfEmail;
	private JTextField tfEndereco;
	private JTextField tfBairro;
	private JLabel lblUF;
	private JButton btnSalvar,btnCancelar;
	public ControleFuncionario controleFuncionario;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TelaFuncionario frame = new TelaFuncionario();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TelaFuncionario() {
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 604, 480);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JLabel lblFuncionario = new JLabel("Funcionario");
		
		tfFuncionario = new JTextField();
		tfFuncionario.setColumns(10);
		
		JLabel lblDataAdmissão = new JLabel("Data Admiss\u00E3o");
		
		tfData = new JTextField();
		tfData.setColumns(10);
		
		JLabel lblTelefone = new JLabel("Telefone");
		
		tfFone = new JTextField();
		tfFone.setColumns(10);
		
		JLabel lblCpf = new JLabel("CPF");
		
		tfCpf = new JTextField();
		tfCpf.setColumns(10);
		
		JLabel lblRg = new JLabel("RG");
		
		tfRg = new JTextField();
		tfRg.setColumns(10);
		
		JLabel lblSexo = new JLabel("Sexo");
		
		tfSexo = new JTextField();
		tfSexo.setColumns(10);
		
		JLabel lblCargo = new JLabel("Cargo");
		
		tfCargo = new JTextField();
		tfCargo.setColumns(10);
		
		JLabel lblEstadocivil = new JLabel("EstadoCivil");
		
		tfEstCivil = new JTextField();
		tfEstCivil.setColumns(10);
		
		JLabel lblExpediente = new JLabel("Expediente");
		
		tfExpediente = new JTextField();
		tfExpediente.setColumns(10);
		
		JLabel lblFacebook = new JLabel("Facebook");
		
		tfFacebook = new JTextField();
		tfFacebook.setColumns(10);
		
		JLabel lblEmail = new JLabel("Email");
		
		tfEmail = new JTextField();
		tfEmail.setColumns(10);
		
		JLabel lblEndereo = new JLabel("Endere\u00E7o");
		
		tfEndereco = new JTextField();
		tfEndereco.setColumns(10);
		
		JLabel lblBairro = new JLabel("Bairro");
		
		tfBairro = new JTextField();
		tfBairro.setColumns(10);
		
		lblUF = new JLabel("UF");
		final JComboBox cbUf = new JComboBox();
		cbUf.setModel(new DefaultComboBoxModel(new String[] {"Selecione", "Acre (AC)", "Alagoas (AL)", "Amazonas (AM)", "Amap\u00E1 (AP)", "Bahia (BA)", "Cear\u00E1 (CE)", "Distrito Federal (DF)", "Esp\u00EDrito Santo (ES)", "Goi\u00E1s (GO)", "Maranh\u00E3o (MA)", "Mato Grosso (MT)", "Mato Grosso do Sul (MS)", "Minas Gerais (MG)", "Par\u00E1 (PA)", "Para\u00EDba (PB)", "Paran\u00E1 (PR)", "Pernambuco (PE)", "Piau\u00ED (PI)", "Rio de Janeiro (RJ)", "Rio Grande do Norte (RN)", "Rio Grande do Sul (RS)", "Rond\u00F4nia (RO)", "Roraima (RR)", "Santa Catarina (SC)", "S\u00E3o Paulo (SP)", "Sergipe (SE)", "Tocantins (TO)"}));		
		
		btnCancelar = new JButton("Cancelar");
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		
		btnSalvar = new JButton("Salvar");
		btnSalvar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ControleFuncionario controleFuncionario = new ControleFuncionario(); 
				Funcionario funcionario = new Funcionario();
				funcionario.setBairro(tfBairro.getText());
				funcionario.setCargo(tfCargo.getText());
				funcionario.setCpf(tfCpf.getText());
				funcionario.setData(tfData.getText());
				funcionario.setEmail(tfEmail.getText());
				funcionario.setEndereco(tfEndereco.getText());
				funcionario.setEstadoCivil(tfEstCivil.getText());
				funcionario.setExpediente(tfExpediente.getText());
				funcionario.setFacebook(tfFacebook.getText());
				funcionario.setRg(tfRg.getText());
				funcionario.setSexo(tfSexo.getText());
				cbUf.setSelectedIndex(DEFAULT_CURSOR);
				JOptionPane.showMessageDialog(null,"formulario salvo com sucesso");
				controleFuncionario.salvarFuncionario(funcionario);
				controleFuncionario.fecharSessao(funcionario);
				
			}
		});
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(19)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(24)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(lblDataAdmissão)
								.addComponent(lblFuncionario)
								.addComponent(lblFacebook)
								.addComponent(lblExpediente)
								.addComponent(lblTelefone)
								.addComponent(lblEmail)
								.addComponent(lblUF))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(cbUf, 0, 215, Short.MAX_VALUE)
								.addComponent(tfExpediente, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
								.addComponent(tfFacebook, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
								.addComponent(tfFone, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
								.addComponent(tfFuncionario, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
								.addComponent(tfData, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
								.addComponent(tfEmail, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(btnCancelar)
							.addPreferredGap(ComponentPlacement.RELATED)))
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(72)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_contentPane.createSequentialGroup()
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addComponent(lblEndereo)
										.addComponent(lblCargo)
										.addComponent(lblBairro))
									.addGap(18)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
										.addComponent(tfCargo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
										.addComponent(tfEndereco, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
										.addComponent(tfBairro, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
								.addGroup(gl_contentPane.createSequentialGroup()
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addComponent(lblCpf)
										.addComponent(lblEstadocivil)
										.addComponent(lblRg)
										.addComponent(lblSexo))
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_contentPane.createSequentialGroup()
											.addGap(11)
											.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
												.addComponent(tfEstCivil, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
												.addComponent(tfSexo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
												.addComponent(tfRg, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)))
										.addGroup(gl_contentPane.createSequentialGroup()
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(tfCpf, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE))))))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(86)
							.addComponent(btnSalvar, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(37)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_contentPane.createSequentialGroup()
									.addGap(83)
									.addComponent(lblExpediente))
								.addGroup(gl_contentPane.createSequentialGroup()
									.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
										.addComponent(lblFuncionario)
										.addComponent(tfFuncionario, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
										.addComponent(lblDataAdmissão)
										.addComponent(tfData, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
										.addComponent(lblTelefone)
										.addComponent(tfFone, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(tfExpediente, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblFacebook)
								.addComponent(tfFacebook, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(tfEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblEmail))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblUF)
								.addComponent(cbUf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblCpf)
								.addComponent(tfCpf, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblRg)
								.addComponent(tfRg, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(tfEstCivil, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblEstadocivil))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblSexo, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
								.addComponent(tfSexo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(tfCargo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblCargo))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(tfEndereco, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblEndereo))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblBairro, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
								.addComponent(tfBairro, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addPreferredGap(ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnSalvar)
						.addComponent(btnCancelar))
					.addGap(66))
		);
		contentPane.setLayout(gl_contentPane);
	}
}
